package com.foreknow.oppExer1.exer10;

import java.util.Calendar;

/**
 * @author shkstart
 * @create 2021-07-28 15:33
 */
public class PayrollSystem {
    public static void main(String[] args) {
        Employee[] employees=new Employee[3];
        Employee s1=new SalariedEmployee("s1","1",new MyDate(1999,12,20),6000);
        Employee h1=new HourlyEmployee("h1","2",new MyDate(1998,7,20),50,150);
        Employee h2=new HourlyEmployee("h2","3",new MyDate(1998,6,20),50,150);
        employees[0]=s1;
        employees[1]=h1;
        employees[2]=h2;
        Calendar cal = Calendar.getInstance();
        int month = cal.get(Calendar.MONTH) + 1;
//        for (Employee arr:employees) {
//            System.out.println(arr.earnings());
//        }

        System.out.println(month);
        for (int i = 0; i < employees.length; i++) {
            if(employees[i].getBirthday().getMonth()==month){
                System.out.println(employees[i].getName()+"生日快乐，奖励666元");
                employees[i].setBirsalary(666);
                System.out.println(employees[i].toString()+"工资为"+employees[i].earnings());
            }else {
                System.out.println(employees[i].toString()+"工资为"+employees[i].earnings());
            }
        }
    }


}
